<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="<c:url value='/js/jquery-1.11.1.min.js'/>"></script>
<script src="js/bootstrap.min.js"></script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>订单管理</title>
<script type="text/javascript">
	function changePage(method) {
		
		var pageNo = document.forms[0].pageNo.value;
		var total = document.forms[0].total.value;
		if (method == "next") {
			if (parseInt(pageNo) >= parseInt(total)) {
				alert("当前已经是最后一页！");
				return false;
			} else {
				document.forms[0].pageNo.value = parseInt(pageNo) + 1;
			}
		}
		if (method == "previous") {
			if (parseInt(pageNo) <= 1) {
				alert("当前已经是第一页");
				return false;
			} else {
				document.forms[0].pageNo.value = parseInt(pageNo) - 1;
			}
		}
		if (method == "first") {
			document.forms[0].pageNo.value = 1;
		}
		if (method == "end") {
			document.forms[0].pageNo.value = total;
		}

		document.forms[0].submit();
	}
</script>
</head>

<body>

		<form action="<c:url value='/AdminInfoAction?oper=ordermanage'/>" method="post">
			<input type="hidden" name="pageNo" value="${pageNo}"> 
			<input type="hidden" name="total" value="${total}"> 
		</form>
		
		<nav class="navbar navbar-default" role="navigation">
   <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" 
         data-target="#example-navbar-collapse">
         <span class="sr-only">切换导航</span>
         <span class="icon-bar"></span>
         <span class="icon-bar"></span>
         <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="<c:url value='/AdminInfoAction?oper=back'/>">欢迎您：${adminInfologin.adminName }</a>
   </div>
   <div class="collapse navbar-collapse" id="example-navbar-collapse">
      <ul class="nav navbar-nav">
          <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">用户管理<b class="caret"></b>
            </a>
            <ul class="dropdown-menu">
               <li><a href="<c:url value='/AdminInfoAction?oper=userlist'/>">用户列表</a></li>
            </ul>
         </li>
         <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">订单管理<b class="caret"></b>
            </a>
            <ul class="dropdown-menu">
               <li><a href="<c:url value='/AdminInfoAction?oper=ordermanage'/>">订单列表</a></li>
            </ul>
         </li>
         <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">衣服管理<b class="caret"></b>
            </a>
            <ul class="dropdown-menu">
               <li><a href="<c:url value='/ClothingAction?oper=clothinglist'/>">查看所有衣服</a></li>
               <li><a href="<c:url value='/ClothingAction?oper=clothingsave'/>">上架衣服</a></li>
            </ul>
         </li>
          <li><a href="<c:url value='/AdminInfoAction?oper=loginout'/>">退出登录</a></li>
      </ul>
   </div>
</nav>
	
	
	<table>
		<tr>
			<td>订单编号</td>
			<td>用户名</td>
			<td>总价</td>
			<td>地址</td>
			<td>电话</td>
			<td>是否支付</td>
			<td>是否发货</td>
			<td>上架时间</td>

		</tr>


		<c:forEach items="${orderlist }" var="orderInfo">
			<tr>
				<td>${orderInfo.id }</td>
				<td>${orderInfo.userInfo.userName }</td>
				<td>${orderInfo.total }</td>
				<td>${orderInfo.userInfo.address}</td>
				<td>${orderInfo.userInfo.phone }</td>
			
			<c:if test="${orderInfo.isPay==0 }">
				<td><a href="<c:url value='/OrderAction?oper=updateisPay&id=${orderInfo.id }&pageNo=${pageNo}'/>">确认支付</a></td>
				</c:if>
				<c:if test="${orderInfo.isPay!=0 }">
				<td>已付款</td>
				</c:if>
				
			<c:if test="${orderInfo.isPay!=0 }">
				<c:if test="${orderInfo.isDeliver==0 }">
				<td><a href="<c:url value='/OrderAction?oper=updateisDeliver&id=${orderInfo.id }&pageNo=${pageNo}'/>">确认发货</a></td>
				</c:if>
				<c:if test="${orderInfo.isDeliver!=0 }">
				<td>已发货</td>
				</c:if>
			</c:if>
			
			<c:if test="${orderInfo.isPay==0 }">
			<td>未发货</td>
			
			</c:if>
				
				<td>${orderInfo.orderTime }</td>
				<td>
				<a href="<c:url value='/AdminInfoAction?oper=orderlist&id=${orderInfo.id }'/>">订单明细</a>
				</td>
			</tr>
		</c:forEach>

		<tr>
			<td colspan="3">查询到：${count}条记录
			<a href="#" onclick="changePage('first')">首页</a> 
			<a href="#" onclick="changePage('previous')">上一页</a> 
			<a href="#" onclick="changePage('next')">下一页</a>
			 第${ pageNo}页/共${total}页
			<a href="#" onclick="changePage('end')">尾页</a>
			</td>
		</tr>
	</table>
</body>
</html>